import React, { createContext } from 'react'
import loadable from '@loadable/component';
import './App.less'
import store from './store'
import { Observer } from 'mobx-react';

const ContextAPI = createContext()

const App = () => {
  return (
    <ContextAPI.Provider value={store}>
      <Observer>
        {() => {
          let Page
          if (store.login.isLand) {
            Page = loadable(() => import('./pages/main'))
          } else {
            Page = loadable(() => import('./pages/login'))
          }

          return <Page />
        }}
      </Observer>
    </ContextAPI.Provider>
  )
}

export default App
export {
  ContextAPI
}

